import { Message, Loading } from 'element-ui'
let loading = undefined
export function showLoading(message = '上传中...'){
  loading = Loading.service({
    lock: true,
    text: message,
    background: "rgba(0, 0, 0, 0.7)",
  });
}
export function clearLoading(){
  if(loading) {
    loading.close();
    loading = undefined
  }
}
export function showError(message){
  if(message){
    Message({
      message: message || 'Error',
      type: 'error',
      duration: 5 * 1000
    })
  }
}
export function showWarning(message){
  if(message){
    Message({
      message: message || 'Error',
      type: 'warning',
      duration: 5 * 1000
    })
  }
}
export function showSuccess(message){
  if(message){
    Message({
      message: message || 'Error',
      type: 'success',
      duration: 5 * 1000
    })
  }
}

